<?php
  class Plugins_Vdouploadcover extends model {
  
  
  
  function getformadd($productid="")
  {
  

  

  
  
//  $str='<div>VDO<div class="vdoclass" style="width:640px;height:360px"></div><div><input type="button" name="link[]" value="link"></div></div>';
 
  $str='<div class="wrpPlg clBg5 clBd2 bdFull">
                    <div class="plgArea"></div>
                    <div class="wrpOutAtcPlg">
                        <div class="wrpAtcPlg">
                            <span class="ico icoOri icoVdoPlg"></span>
                            <div class="spnAtcPlg clTxtW">
                                <span class="txtAtcPlg fs03">MP4 Upload</span>
                                <br>
                                <span class="rcmSizeAdd fs01">+ Video Cover</span>
                            </div>
                        </div>
                    </div>
                    <div class="wrpTl">
                        <div title="Close" class="btnIco closeTl clBd3 mgBtm10 deleterowbutton">
                            <span class="ico icoCloseTl"></span>
                        </div>
                        <div class="addTool">
                        
                            <div title="Link" class="btnIco addVdoUlTl clBd3 bdBtm linkvdobutton">
                                <span class="ico icoVdoUlPlg"></span>
                                <div class="wrpUlFile">

                                </div>
                            </div>
                            
                            
                            <div title="Cover" class="btnIco addImgTl clBd3 bdBtm cvrPop imgvdobutton">
                                <span class="ico icoAddImgTl"></span>
                            </div>
                            
                            
                            
                            <div title="Remove" class="btnIco btnRmvTl deletevdobutton">
                                <span class="ico icoRmvTl"></span>
                            </div>
                            
                        </div>
                    </div>
                    <span class="desPlg clTxt3 fs03">Explain more about your stuff by add some vdo clip for it.(MP4 Only)</span>
                    
                    
                    
                </div>
                <form onsubmit="return false;" class="frmTprPlgAdd2"><input type="text" placeholder="desc" class="inpAddCtntNoBd inpTprPlg w616 clTxt2 fs03" name="detail[]">                        </form>
                
                ';
 
 
  $arraydata['form']=addslashes(str_replace(array("\r", "", "\r"), '', $str));
 // $arraydata['js'][]=pluginjsinfo.'/vdo.js';


  
  
      
  
  
  
  return $arraydata;
  
  
  
  
  
  
  
  }
  
  function getformlanding($arraydata)
  {
  $code='<div class="wrpVdoLdcheckrow" id="uploadvdoid2-'.$arraydata['uploadid'].'">';;
  $code.= '<div class="ldIt wrpVdoLd clBg4 w640" id="uploadvdoid-'.$arraydata['uploadid'].'">';
  
 if(strpos($arraydata['file']['newpath'],'mp4')!==false )
{



$code .='<video width="100%" height="360" id="uploadvdoidsetscript-'.$arraydata['uploadid'].'" src="'.$arraydata['file']['newpath'].'" controls><source src="'.$arraydata['file']['newpath'].'" type="video/mp4"></video>';








}else
{
//$code .=' <iframe width="100%" height="360" src="'.$arraydata['url'].'"> </iframe>';
} 
  $code .= '</div>';
  $code .= '</div>';

$data['str']=$code;
$data['target']='secondtarget';







$data['script']='MediaElement(\'uploadvdoidsetscript-'.$arraydata['uploadid'].'\', {success: function(me) {
    
 $(\'#main-middle .wrpVdoLdcheckrow div div\').click(function() {
          if (me.paused)
            me.play();
        else
            me.pause();
        });

}});';

//$code .='<embed width="100%" height="360" name="plugin" src="'.$arraydata['file']['newpath'].'" type="video/mp4">';





return $data;
  
  
  }
  
  function getplugin($plugreid)
  {
  
  $sql="select * from tb_plugins_vdouploadcover where plugreid=".$plugreid;
  $arrayplugin=$this->db->db_set_1recordrow($sql);
  
    $arrayplugin['file']=array();
  
  if($arrayplugin['fileid'])
  {
  $sql="select (CONCAT('". baseinfo . "','/', path)) as newpath,filename,name,tb_file.size from tb_file where fileid=".$arrayplugin['fileid'];
  $arrayfile=$this->db->db_set_1recordrow($sql);
  $arrayplugin['file']=$arrayfile;
  }
  
  
    $arrayplugin['img']= $this->getimagebyimgmid($arrayplugin['imgmid']);
     $arrayplugin['simg']= $this->getimagebyimgmid($arrayplugin['simgmid']);

  return $arrayplugin;
  
  

  
  }
  
  function saveplugin($arraydata,$productid,$plugreid)
  {
  
  
  
  
  $sql="select path,productid,name from tb_file where fileid=".$arraydata['fileid'];
  $arrayfile=$this->db->db_set_1recordrow($sql);
  
  if($arrayfile['productid']==0)
  { 
     $newpath=filepath.'/'.$productid.'/'.$arrayfile['name']   ;
     if(copy($arrayfile['path'],$newpath))
     {
     @chmod($newpath,0777);
     unlink($arrayfile['path']);
     $arrayfile['cache']=0;
     $arrayfile['path']=str_replace(rootpath.'/','',$newpath);
     $arrayfile['productid']=$productid;
     $this->db->db_set($arrayfile,'tb_file',' fileid='.$arraydata['fileid']);
     
     
     }
     
     
  
  }
  
  
   if($arraydata['simgmid'])$arraydata['simgmid']=$this->swicthpathimage($arraydata['simgmid'],$productid);
 
   if($arraydata['imgmid'])
  {
  $arraydata['imgmid']=$this->swicthpathimage($arraydata['imgmid'],$productid);
  
  }
  
  
  
  $arraydata['productid']=$productid;
  $arraydata['plugreid']=$plugreid;
  $this->db->db_set($arraydata,'tb_plugins_vdouploadcover');
  
  } 
  
  
  }
?>
